#include "TemplatexPLItem.h"

TemplatexPLItem::TemplatexPLItem()
{
    name = "";
    type = "";
    defaultValue = "";
}

TemplatexPLItem::TemplatexPLItem(const QString &name, const QString& type, const QString& defautlValue)
{
    this->name = name;
    this->type = type;
    this->defaultValue = defaultValue;
}

TemplatexPLItem::TemplatexPLItem(const TemplatexPLItem &other)
{
    this->name = other.name;
    this->type = other.type;
    this->defaultValue = other.defaultValue;
}

TemplatexPLItem::~TemplatexPLItem()
{

}

TemplatexPLItem& TemplatexPLItem::operator=(const TemplatexPLItem& other)
{
    this->name = other.name;
    this->type = other.type;
    this->defaultValue = other.defaultValue;
    return *this;
}

bool TemplatexPLItem::equals(const TemplatexPLItem &other) const
{
    return (this->type == other.type && this->name == other.name && this->defaultValue == other.defaultValue);
}

QString TemplatexPLItem::toString() const
{
    return this->toXml();
}

QString TemplatexPLItem::toXml() const
{
    QString rslt = "<item name=\"%1\" type=\"%2\" default=\"%3\" />";
    return rslt.arg(name).arg(type).arg(defaultValue);
}

bool operator==(const TemplatexPLItem& a, const TemplatexPLItem& b)
{
    return a.equals(b);
}

bool operator!=(const TemplatexPLItem& a, const TemplatexPLItem& b)
{
    return !a.equals(b);
}
